package com.novabluetooth.adapter;

import com.health.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 主菜单布局adapter【体检】
 */
public class SBCLMenuGridAdapter extends BaseAdapter {
	private int[] imgs;
	private String[] names;
	private int[] colors;
	private Context mContext;
	 

	public SBCLMenuGridAdapter(Context mContext) {
		this.mContext = mContext;

 		imgs = new int[] { R.drawable.sbcl_tiwen, R.drawable.sbcl_xueya, R.drawable.sbcl_xuetang,
 				R.drawable.sbcl_tizhong, R.drawable.sbcl_xueyang, R.drawable.sbcl_niaochanggui};
		names = new String[] { "体温", "血压", "血糖", "体重","血氧", "尿常规"};
		colors = new int[] { 0xff71B57C, 0xff71B57C, 0xff71B57C, 0xff71B57C, 0xff71B57C, 0xff71B57C};// ,
	}

	@Override
	public int getCount() {
		return names.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(R.layout.bluetooth_sbcl_griditem, null);
			vh = new ViewHolder();
			int drawableID = imgs[position];
			String name = names[position];
			int color = colors[position];
			findView(vh, convertView, drawableID, name, color,position);
			convertView.setTag(R.id.TAG_VIEWHOLDER, vh);
		} else
			vh = (ViewHolder) convertView.getTag(R.id.TAG_VIEWHOLDER);

		setData(vh, convertView, position);

		return convertView;
	}

	/**
	 * 赋值
	 * 
	 * @param h
	 * @param v
	 * @param position
	 * @author 王婷婷
	 * @date 2015年12月3日 上午10:24:28
	 */
	private void setData(ViewHolder h, View v, int position) {
	}

	private void findView(ViewHolder h, View v, int drawableID, String name, int color,int position) {
		h.img = (ImageView) v.findViewById(R.id.norm_img);
		h.nameText = (TextView) v.findViewById(R.id.norm_name);

		h.img.setImageResource(drawableID);
		h.nameText.setText(name);
//		h.nameText.setTextColor(color);
		
	}

	private static class ViewHolder {
		ImageView img;
		TextView nameText;
	}

}
